// 登录相关接口
import request from '../utils/request'

interface IGetQRcodeKeyApi {
	code: number,
	data: {
		readonly unikey: string,
		code: string
	}
}
// 二维码 key 生成接口
export const getQRcodeKeyApi = () => request.post<any, IGetQRcodeKeyApi>(`/login/qr/key?addtime=true`)

interface ICreateQRcodeApi {
	code: number,
	data: {
		qrimg: string,
		qrurl: string
	}
}
// 二维码生成接口
export const createQRcodeApi = (key: string) => request.post<any, ICreateQRcodeApi>(`/login/qr/create?key=${key}&qrimg=true&addtime=true`)


interface ICheckQRcodeApi {
	code: number,
	cookie?: string,
	message: string
}
// 二维码检测扫码状态接口
export const checkQRcodeApi = (key: string) => request.post<any, ICheckQRcodeApi>(`/login/qr/check?key=${ key }&addtime=true`)

interface IVisitorLoginApi {
	code: number,
	cookie: string,
	createTime: number,
	readonly userId: number
}
// 游客登录接口
export const visitorLoginApi = () => request.post<any, IVisitorLoginApi>('/register/anonimous')